<template>
  <view>
    <view class="area-city">
      <text class="city">贵阳市</text>
    </view>
    <view class="area-region">
      <u-list>
        <u-list-item v-for="(item, index) in areaList" :key="index">
          <u-cell :title="item.name" @click="selectSchool(item.code)"></u-cell>
        </u-list-item>
      </u-list>
    </view>
  </view>
</template>

<script>
import {getAreasByActivityId} from "../../../api/supervise/index.js"

export default {
  data() {
    return {
      activityId: 0,
      areaList: []
    }
  },
  onLoad(option) {
    if (Object.keys(option).length > 0) {
      const activityId = JSON.parse(decodeURIComponent(option.activityId));
      this.activityId = activityId;
      this.getAreasByActivityId();
    }

  },
  methods: {
    selectSchool(code) {
      uni.$u.route('/pages/index/viewVideo/school', {
        code,
        activityId: this.activityId
      });
    },
    getAreasByActivityId() {
      getAreasByActivityId(this.activityId).then(res => {
        this.areaList = res.areas;
      });
    }
  }
}
</script>

<style lang="scss" scoped>
.area-city {
  height: 6vh;
  line-height: 6vh;

  .city {
    padding-left: 5px;
  }
}

.area-region {
  text-align: center;
  background-color: #fff;

}
</style>